home *** CD-ROM | disk | FTP | other *** search
/ Aminet 35 / Aminet 35 (2000)(Schatztruhe)[!][Feb 2000].iso / Aminet / game / shoot / ADescentSrc.lha / descent / main / songs.c < prev    next >
C/C++ Source or Header  |  1998-04-03  |  3KB  |  123 lines

  1. /*
  2. THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX
  3. SOFTWARE CORPORATION ("PARALLAX").  PARALLAX, IN DISTRIBUTING THE CODE TO
  4. END-USERS, AND SUBJECT TO ALL OF THE TERMS AND CONDITIONS HEREIN, GRANTS A
  5. ROYALTY-FREE, PERPETUAL LICENSE TO SUCH END-USERS FOR USE BY SUCH END-USERS
  6. IN USING, DISPLAYING,  AND CREATING DERIVATIVE WORKS THEREOF, SO LONG AS
  7. SUCH USE, DISPLAY OR CREATION IS FOR NON-COMMERCIAL, ROYALTY OR REVENUE
  8. FREE PURPOSES.  IN NO EVENT SHALL THE END-USER USE THE COMPUTER CODE
  9. CONTAINED HEREIN FOR REVENUE-BEARING PURPOSES.  THE END-USER UNDERSTANDS
  10. AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE.  
  11. COPYRIGHT 1993-1998 PARALLAX SOFTWARE CORPORATION.  ALL RIGHTS RESERVED.
  12. */
  13. /*
  14.  * $Source: /usr/CVS/descent/main/songs.c,v $
  15.  * $Revision: 1.2 $
  16.  * $Author: hfrieden $
  17.  * $Date: 1998/04/03 13:35:43 $
  18.  * 
  19.  * Routines to manage the songs in Descent.
  20.  * 
  21.  * $Log: songs.c,v $
  22.  * Revision 1.2  1998/04/03 13:35:43  hfrieden
  23.  * Fixed nosong switch
  24.  *
  25.  * Revision 1.1.1.1  1998/03/03 15:12:32  nobody
  26.  * reimport after crash from backup
  27.  *
  28.  * Revision 1.2  1998/02/28 00:40:41  hfrieden
  29.  * Added -nosongs switch for MAC HOG file (hopefully)
  30.  *
  31.  * Revision 1.1.1.1  1998/02/13 20:21:04  hfrieden
  32.  * Initial Import
  33.  *
  34.  * Revision 2.1  1995/05/02  16:15:21  john
  35.  * Took out printf.
  36.  * 
  37.  * Revision 2.0  1995/02/27  11:27:13  john
  38.  * New version 2.0, which has no anonymous unions, builds with
  39.  * Watcom 10.0, and doesn't require parsing BITMAPS.TBL.
  40.  * 
  41.  * Revision 1.2  1995/02/11  12:42:12  john
  42.  * Added new song method, with FM bank switching..
  43.  * 
  44.  * Revision 1.1  1995/02/11  10:20:33  john
  45.  * Initial revision
  46.  * 
  47.  * 
  48.  */
  49.  
  50.  
  51. #pragma off (unreferenced)
  52. static char rcsid[] = "$Id: songs.c,v 1.2 1998/04/03 13:35:43 hfrieden Exp $";
  53. #pragma on (unreferenced)
  54.  
  55. #include <stdlib.h>
  56. #include <string.h>
  57.  
  58. #include "error.h"
  59. #include "types.h"
  60. #include "songs.h"
  61. #include "mono.h"
  62. #include "cfile.h"
  63. #include "digi.h"
  64.  
  65. song_info Songs[MAX_SONGS];
  66. int Songs_initialized = 0;
  67.  
  68. void songs_init()
  69. {
  70.     int i;
  71.     char inputline[80+1];
  72.     CFILE * fp;
  73.  
  74.     if ( Songs_initialized ) return;
  75.  
  76.     if (FindArg("-nosongs")) {
  77.         Songs_initialized=1;
  78.         return;
  79.     }
  80.  
  81.     fp = cfopen( "descent.sng", "rb" );
  82.     if ( fp == NULL )   {
  83.         Error( "Couldn't open descent.sng" );
  84.     }
  85.  
  86.     i = 0;
  87.     while (cfgets(inputline, 80, fp )) {
  88.         char *p = strchr(inputline,'\n');
  89.         if (p) *p = '\0';
  90.         if ( strlen( inputline ) )  {
  91.             Assert( i < MAX_SONGS );
  92.             sscanf( inputline, "%s %s %s", Songs[i].filename, Songs[i].melodic_bank_file, Songs[i].drum_bank_file );
  93.             //printf( "%d. '%s' '%s' '%s'\n",i,  Songs[i].filename, Songs[i].melodic_bank_file, Songs[i].drum_bank_file );
  94.             i++;
  95.         }
  96.     }
  97.     Songs_initialized = 1;
  98.     cfclose(fp);
  99. }
  100.  
  101. void songs_play_song( int songnum, int repeat )
  102. {
  103.     if ( !Songs_initialized ) songs_init();
  104.     digi_play_midi_song( Songs[songnum].filename, Songs[songnum].melodic_bank_file, Songs[songnum].drum_bank_file, repeat );
  105. }
  106.  
  107. void songs_play_level_song( int levelnum )
  108. {
  109.     int songnum;
  110.  
  111.     Assert( levelnum != 0 );
  112.  
  113.     if ( !Songs_initialized ) songs_init();
  114.  
  115.     if (levelnum < 0)   
  116.         songnum = (-levelnum) % NUM_GAME_SONGS;
  117.     else 
  118.         songnum = (levelnum-1) % NUM_GAME_SONGS;
  119.     
  120.     songnum += SONG_LEVEL_MUSIC;
  121.     digi_play_midi_song( Songs[songnum].filename, Songs[songnum].melodic_bank_file, Songs[songnum].drum_bank_file, 1 );
  122. }
  123.